/*
 *	name : wxRequest.js
 *	description : 封装微信请求
 *	author : 马丰彦
 *	date : 2018-6-20
 */

//封装函数
function request(links, datas) {
    wx.showLoading({
        title: '加载中',
        mask: true
    })
    //返回一个promise实例
    return new Promise((resolve, reject) => {
        var common = {
            'X-Requested-With': 'XMLHttpRequestclient',
            'userListener': 'ctc',
        }
        var obj = Object.assign(common, datas);
        wx.request({
            url: links,
            data: obj,
            header: {
                'content-type': 'application/x-www-form-urlencoded;charset=utf-8'
            },
            success: function(res) {
                resolve(res);
            },
            fail: function(res) {
                reject(res);
            },
            complete: function() {
                //console.log('complete');
				wx.hideLoading();
            }
        })
    })
}
module.exports.request = request